home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / iso / iso-cvt.el < prev    next >
Encoding:
Text File  |  1995-07-05  |  17.1 KB  |  715 lines

  1. ;; iso-cvt.el -- translate to ISO 8859-1 from/to net/TeX conventions
  2. ;; Copyright ⌐ 1993, 1994 Free Software Foundation, Inc.
  3. ;; Was formerly called gm-lingo.el.
  4.  
  5. ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
  6. ;; Keywords: tex, iso, latin, i18n
  7.  
  8. ;; This file is part of GNU Emacs.
  9.  
  10. ;; GNU Emacs is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14.  
  15. ;; GNU Emacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;; GNU General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  22. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24. ;;; Commentary: 
  25. ;; This lisp code serves two purposes, both of which involve 
  26. ;; the translation of various conventions for representing European 
  27. ;; character sets to ISO 8859-1.
  28.  
  29. ; Net support: 
  30. ; Various conventions exist in Newsgroups on how to represent national 
  31. ; characters. The functions provided here translate these net conventions 
  32. ; to ISO.
  33. ;
  34. ; Calling `iso-german' will turn the net convention for umlauts ("a etc.) 
  35. ; into ISO latin1 umlaute for easy reading.
  36. ; 'iso-spanish' will turn net conventions for representing spanish 
  37. ; to ISO latin1. (Note that accents are omitted in news posts most 
  38. ; of the time, only enye is escaped.)
  39.  
  40. ; TeX support
  41. ; This mode installs hooks which change TeX files to ISO Latin-1 for 
  42. ; simplified editing. When the TeX file is saved, ISO latin1 characters are
  43. ; translated back to escape sequences.
  44. ;
  45. ; An alternative is a TeX style that handles 8 bit ISO files 
  46. ; (available on ftp.vlsivie.tuwien.ac.at in /pub/8bit)  
  47. ; - but these files are difficult to transmit ... so while the net is  
  48. ; still @ 7 bit this may be useful
  49.  
  50. ;; TO DO:
  51. ; The net support should install hooks (like TeX support does) 
  52. ; which recognizes certains news groups and translates all articles from 
  53. ; those groups. 
  54. ;
  55. ; Cover more cases for translation (There is an infinite number of ways to 
  56. ; represent accented characters in TeX)
  57.  
  58. ;; SEE ALSO:
  59. ; If you are interested in questions related to using the ISO 8859-1 
  60. ; characters set (configuring emacs, Unix, etc. to use ISO), then you
  61. ; can get the ISO 8859-1 FAQ via anonymous ftp from 
  62. ; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
  63.  
  64. ;;; Code:
  65.  
  66. (provide 'iso-cvt)
  67.  
  68. (defvar iso-spanish-trans-tab
  69.   '(
  70.     ("~n" "±")
  71.     ("\([a-zA-Z]\)#" "\\1±")
  72.     ("~N" "╤")
  73.     ("\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  74.     ("\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  75.     ("\\([-a-zA-Z]\\)'o" "\\1≤")
  76.     ("\\([-a-zA-Z]\\)'O" "\\╙")
  77.     ("\\([-a-zA-Z]\\)'e" "\\1Θ")
  78.     ("\\([-a-zA-Z]\\)'E" "\\1╔")
  79.     ("\\([-a-zA-Z]\\)'a" "\\1ß")
  80.     ("\\([-a-zA-Z]\\)'A" "\\1A")
  81.     ("\\([-a-zA-Z]\\)'i" "\\1φ")
  82.     ("\\([-a-zA-Z]\\)'I" "\\1═")
  83.     )
  84.   "Spanish translation table.")
  85.  
  86. (defun iso-translate-conventions (trans-tab)
  87.   "Use the translation table TRANS-TAB to translate the current buffer."
  88.   (save-excursion
  89.     (goto-char (point-min))
  90.     (let ((work-tab trans-tab)
  91.       (buffer-read-only nil)
  92.       (case-fold-search nil))
  93.       (while work-tab
  94.     (save-excursion
  95.       (let ((trans-this (car work-tab)))
  96.         (while (re-search-forward (car trans-this) nil t)
  97.           (replace-match (car (cdr trans-this)) t nil)))
  98.       (setq work-tab (cdr work-tab)))))))
  99.  
  100. (defun iso-spanish ()
  101.   "Translate net conventions for Spanish to ISO 8859-1."
  102.   (interactive)
  103.   (iso-translate-conventions iso-spanish-trans-tab))
  104.  
  105. (defvar iso-aggressive-german-trans-tab
  106.   '(
  107.     ("\"a" "Σ")
  108.     ("\"A" "─")
  109.     ("\"o" "÷")
  110.     ("\"O" "╓")
  111.     ("\"u" "ⁿ")
  112.     ("\"U" "▄")
  113.     ("\"s" "▀")
  114.     ("\\\\3" "▀")
  115.     )
  116.   "German translation table. 
  117. This table uses an aggressive translation approach and may erroneously
  118. translate too much.")
  119.  
  120. (defvar iso-conservative-german-trans-tab
  121.   '(
  122.     ("\\([-a-zA-Z\"`]\\)\"a" "\\1Σ")
  123.     ("\\([-a-zA-Z\"`]\\)\"A" "\\1─")
  124.     ("\\([-a-zA-Z\"`]\\)\"o" "\\1÷")
  125.     ("\\([-a-zA-Z\"`]\\)\"O" "\\1╓")
  126.     ("\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  127.     ("\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  128.     ("\\([-a-zA-Z\"`]\\)\"s" "\\1▀")
  129.     ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1▀")
  130.     )
  131.   "German translation table.
  132. This table uses a conservative translation approach and may translate too 
  133. little.")
  134.  
  135.  
  136. (defvar iso-german-trans-tab iso-aggressive-german-trans-tab 
  137.   "Currently active translation table for German.")
  138.  
  139. (defun iso-german ()
  140.  "Translate net conventions for German to ISO 8859-1."
  141.  (interactive)
  142.  (iso-translate-conventions iso-german-trans-tab))
  143.  
  144. (defvar iso-iso2tex-trans-tab
  145.   '(
  146.     ("Σ" "{\\\\\"a}")
  147.     ("α" "{\\\\`a}")
  148.     ("ß" "{\\\\'a}")
  149.     ("π" "{\\\\~a}")
  150.     ("Γ" "{\\\\^a}")
  151.     ("δ" "{\\\\\"e}")
  152.     ("Φ" "{\\\\`e}")
  153.     ("Θ" "{\\\\'e}")
  154.     ("Ω" "{\\\\^e}")
  155.     ("∩" "{\\\\\"\\\\i}")
  156.     ("∞" "{\\\\`\\\\i}")
  157.     ("φ" "{\\\\'\\\\i}")
  158.     ("ε" "{\\\\^\\\\i}")
  159.     ("÷" "{\\\\\"o}")
  160.     ("≥" "{\\\\`o}")
  161.     ("≤" "{\\\\'o}")
  162.     ("⌡" "{\\\\~o}")
  163.     ("⌠" "{\\\\^o}")
  164.     ("ⁿ" "{\\\\\"u}")
  165.     ("∙" "{\\\\`u}")
  166.     ("·" "{\\\\'u}")
  167.     ("√" "{\\\\^u}")
  168.     ("─" "{\\\\\"A}")
  169.     ("└" "{\\\\`A}")
  170.     ("┴" "{\\\\'A}")
  171.     ("├" "{\\\\~A}")
  172.     ("┬" "{\\\\^A}")
  173.     ("╦" "{\\\\\"E}")
  174.     ("╚" "{\\\\`E}")
  175.     ("╔" "{\\\\'E}")
  176.     ("╩" "{\\\\^E}")
  177.     ("╧" "{\\\\\"I}")
  178.     ("╠" "{\\\\`I}")
  179.     ("═" "{\\\\'I}")
  180.     ("╬" "{\\\\^I}")
  181.     ("╓" "{\\\\\"O}")
  182.     ("╥" "{\\\\`O}")
  183.     ("╙" "{\\\\'O}")
  184.     ("╒" "{\\\\~O}")
  185.     ("╘" "{\\\\^O}")
  186.     ("▄" "{\\\\\"U}")
  187.     ("┘" "{\\\\`U}")
  188.     ("┌" "{\\\\'U}")
  189.     ("█" "{\\\\^U}")
  190.     ("±" "{\\\\~n}")
  191.     ("╤" "{\\\\~N}")
  192.     ("τ" "{\\\\c c}")
  193.     ("╟" "{\\\\c C}")
  194.     ("▀" "{\\\\ss}")
  195.     ("\306" "{\\\\AE}")
  196.     ("\346" "{\\\\ae}")
  197.     ("\305" "{\\\\AA}")
  198.     ("\345" "{\\\\aa}")
  199.     ("\251" "{\\\\copyright}")
  200.     ("ú" "{\\\\pounds}")
  201.     ("╢" "{\\\\P}")
  202.     ("º" "{\\\\S}")
  203.     ("┐" "{?`}")
  204.     ("í" "{!`}")
  205.     )
  206.   "Translation table for translating ISO 8859-1 characters to TeX sequences.")
  207.  
  208.  
  209.  
  210.  
  211. (defun iso-iso2tex ()
  212.  "Translate ISO 8859-1 characters to TeX sequences."
  213.  (interactive)
  214.  (iso-translate-conventions iso-iso2tex-trans-tab))
  215.  
  216.  
  217. (defvar iso-tex2iso-trans-tab
  218.   '(
  219.     ("{\\\\\"a}" "Σ")
  220.     ("{\\\\`a}" "α")
  221.     ("{\\\\'a}" "ß")
  222.     ("{\\\\~a}" "π")
  223.     ("{\\\\^a}" "Γ")
  224.     ("{\\\\\"e}" "δ")
  225.     ("{\\\\`e}" "Φ")
  226.     ("{\\\\'e}" "Θ")
  227.     ("{\\\\^e}" "Ω")
  228.     ("{\\\\\"\\\\i}" "∩")
  229.     ("{\\\\`\\\\i}" "∞")
  230.     ("{\\\\'\\\\i}" "φ")
  231.     ("{\\\\^\\\\i}" "ε")
  232.     ("{\\\\\"i}" "∩")
  233.     ("{\\\\`i}" "∞")
  234.     ("{\\\\'i}" "φ")
  235.     ("{\\\\^i}" "ε")
  236.     ("{\\\\\"o}" "÷")
  237.     ("{\\\\`o}" "≥")
  238.     ("{\\\\'o}" "≤")
  239.     ("{\\\\~o}" "⌡")
  240.     ("{\\\\^o}" "⌠")
  241.     ("{\\\\\"u}" "ⁿ")
  242.     ("{\\\\`u}" "∙")
  243.     ("{\\\\'u}" "·")
  244.     ("{\\\\^u}" "√")
  245.     ("{\\\\\"A}" "─")
  246.     ("{\\\\`A}" "└")
  247.     ("{\\\\'A}" "┴")
  248.     ("{\\\\~A}" "├")
  249.     ("{\\\\^A}" "┬")
  250.     ("{\\\\\"E}" "╦")
  251.     ("{\\\\`E}" "╚")
  252.     ("{\\\\'E}" "╔")
  253.     ("{\\\\^E}" "╩")
  254.     ("{\\\\\"I}" "╧")
  255.     ("{\\\\`I}" "╠")
  256.     ("{\\\\'I}" "═")
  257.     ("{\\\\^I}" "╬")
  258.     ("{\\\\\"O}" "╓")
  259.     ("{\\\\`O}" "╥")
  260.     ("{\\\\'O}" "╙")
  261.     ("{\\\\~O}" "╒")
  262.     ("{\\\\^O}" "╘")
  263.     ("{\\\\\"U}" "▄")
  264.     ("{\\\\`U}" "┘")
  265.     ("{\\\\'U}" "┌")
  266.     ("{\\\\^U}" "█")
  267.     ("{\\\\~n}" "±")
  268.     ("{\\\\~N}" "╤")
  269.     ("{\\\\c c}" "τ")
  270.     ("{\\\\c C}" "╟")
  271.     ("\\\\\"a" "Σ")
  272.     ("\\\\`a" "α")
  273.     ("\\\\'a" "ß")
  274.     ("\\\\~a" "π")
  275.     ("\\\\^a" "Γ")
  276.     ("\\\\\"e" "δ")
  277.     ("\\\\`e" "Φ")
  278.     ("\\\\'e" "Θ")
  279.     ("\\\\^e" "Ω")
  280.     ("\\\\\"\\\\i" "∩")
  281.     ("\\\\`\\\\i" "∞")
  282.     ("\\\\'\\\\i" "φ")
  283.     ("\\\\^\\\\i" "ε")
  284.     ("\\\\\"i" "∩")
  285.     ("\\\\`i" "∞")
  286.     ("\\\\'i" "φ")
  287.     ("\\\\^i" "ε")
  288.     ("\\\\\"o" "÷")
  289.     ("\\\\`o" "≥")
  290.     ("\\\\'o" "≤")
  291.     ("\\\\~o" "⌡")
  292.     ("\\\\^o" "⌠")
  293.     ("\\\\\"u" "ⁿ")
  294.     ("\\\\`u" "∙")
  295.     ("\\\\'u" "·")
  296.     ("\\\\^u" "√")
  297.     ("\\\\\"A" "─")
  298.     ("\\\\`A" "└")
  299.     ("\\\\'A" "┴")
  300.     ("\\\\~A" "├")
  301.     ("\\\\^A" "┬")
  302.     ("\\\\\"E" "╦")
  303.     ("\\\\`E" "╚")
  304.     ("\\\\'E" "╔")
  305.     ("\\\\^E" "╩")
  306.     ("\\\\\"I" "╧")
  307.     ("\\\\`I" "╠")
  308.     ("\\\\'I" "═")
  309.     ("\\\\^I" "╬")
  310.     ("\\\\\"O" "╓")
  311.     ("\\\\`O" "╥")
  312.     ("\\\\'O" "╙")
  313.     ("\\\\~O" "╒")
  314.     ("\\\\^O" "╘")
  315.     ("\\\\\"U" "▄")
  316.     ("\\\\`U" "┘")
  317.     ("\\\\'U" "┌")
  318.     ("\\\\^U" "█")
  319.     ("\\\\~n" "±")
  320.     ("\\\\~N" "╤")
  321.     ("\\\\\"{a}" "Σ")
  322.     ("\\\\`{a}" "α")
  323.     ("\\\\'{a}" "ß")
  324.     ("\\\\~{a}" "π")
  325.     ("\\\\^{a}" "Γ")
  326.     ("\\\\\"{e}" "δ")
  327.     ("\\\\`{e}" "Φ")
  328.     ("\\\\'{e}" "Θ")
  329.     ("\\\\^{e}" "Ω")
  330.     ("\\\\\"{\\\\i}" "∩")
  331.     ("\\\\`{\\\\i}" "∞")
  332.     ("\\\\'{\\\\i}" "φ")
  333.     ("\\\\^{\\\\i}" "ε")
  334.     ("\\\\\"{i}" "∩")
  335.     ("\\\\`{i}" "∞")
  336.     ("\\\\'{i}" "φ")
  337.     ("\\\\^{i}" "ε")
  338.     ("\\\\\"{o}" "÷")
  339.     ("\\\\`{o}" "≥")
  340.     ("\\\\'{o}" "≤")
  341.     ("\\\\~{o}" "⌡")
  342.     ("\\\\^{o}" "⌠")
  343.     ("\\\\\"{u}" "ⁿ")
  344.     ("\\\\`{u}" "∙")
  345.     ("\\\\'{u}" "·")
  346.     ("\\\\^{u}" "√")
  347.     ("\\\\\"{A}" "─")
  348.     ("\\\\`{A}" "└")
  349.     ("\\\\'{A}" "┴")
  350.     ("\\\\~{A}" "├")
  351.     ("\\\\^{A}" "┬")
  352.     ("\\\\\"{E}" "╦")
  353.     ("\\\\`{E}" "╚")
  354.     ("\\\\'{E}" "╔")
  355.     ("\\\\^{E}" "╩")
  356.     ("\\\\\"{I}" "╧")
  357.     ("\\\\`{I}" "╠")
  358.     ("\\\\'{I}" "═")
  359.     ("\\\\^{I}" "╬")
  360.     ("\\\\\"{O}" "╓")
  361.     ("\\\\`{O}" "╥")
  362.     ("\\\\'{O}" "╙")
  363.     ("\\\\~{O}" "╒")
  364.     ("\\\\^{O}" "╘")
  365.     ("\\\\\"{U}" "▄")
  366.     ("\\\\`{U}" "┘")
  367.     ("\\\\'{U}" "┌")
  368.     ("\\\\^{U}" "█")
  369.     ("\\\\~{n}" "±")
  370.     ("\\\\~{N}" "╤")
  371.     ("\\\\c{c}" "τ")
  372.     ("\\\\c{C}" "╟")
  373.     ("{\\\\ss}" "▀")
  374.     ("{\\\\AE}" "\306")
  375.     ("{\\\\ae}" "\346")
  376.     ("{\\\\AA}" "\305")
  377.     ("{\\\\aa}" "\345")
  378.     ("{\\\\copyright}" "\251")
  379.     ("\\\\copyright{}" "\251")
  380.     ("{\\\\pounds}" "ú" )
  381.     ("{\\\\P}" "╢" )
  382.     ("{\\\\S}" "º" )
  383.     ("\\\\pounds{}" "ú" )
  384.     ("\\\\P{}" "╢" )
  385.     ("\\\\S{}" "º" )
  386.     ("{\\?`}" "┐")
  387.     ("{!`}" "í")
  388.     ("\\?`" "┐")
  389.     ("!`" "í")
  390.     )
  391.   "Translation table for translating TeX sequences to ISO 8859-1 characters. 
  392. This table is not exhaustive (and due to TeX's power can never be). It only
  393. contains commonly used sequences.")
  394.  
  395. (defun iso-tex2iso ()
  396.  "Translate TeX sequences to ISO 8859-1 characters."
  397.  (interactive)
  398.  (iso-translate-conventions iso-tex2iso-trans-tab))
  399.  
  400. (defvar iso-gtex2iso-trans-tab
  401.   '(
  402.     ("{\\\\\"a}" "Σ")
  403.     ("{\\\\`a}" "α")
  404.     ("{\\\\'a}" "ß")
  405.     ("{\\\\~a}" "π")
  406.     ("{\\\\^a}" "Γ")
  407.     ("{\\\\\"e}" "δ")
  408.     ("{\\\\`e}" "Φ")
  409.     ("{\\\\'e}" "Θ")
  410.     ("{\\\\^e}" "Ω")
  411.     ("{\\\\\"\\\\i}" "∩")
  412.     ("{\\\\`\\\\i}" "∞")
  413.     ("{\\\\'\\\\i}" "φ")
  414.     ("{\\\\^\\\\i}" "ε")
  415.     ("{\\\\\"i}" "∩")
  416.     ("{\\\\`i}" "∞")
  417.     ("{\\\\'i}" "φ")
  418.     ("{\\\\^i}" "ε")
  419.     ("{\\\\\"o}" "÷")
  420.     ("{\\\\`o}" "≥")
  421.     ("{\\\\'o}" "≤")
  422.     ("{\\\\~o}" "⌡")
  423.     ("{\\\\^o}" "⌠")
  424.     ("{\\\\\"u}" "ⁿ")
  425.     ("{\\\\`u}" "∙")
  426.     ("{\\\\'u}" "·")
  427.     ("{\\\\^u}" "√")
  428.     ("{\\\\\"A}" "─")
  429.     ("{\\\\`A}" "└")
  430.     ("{\\\\'A}" "┴")
  431.     ("{\\\\~A}" "├")
  432.     ("{\\\\^A}" "┬")
  433.     ("{\\\\\"E}" "╦")
  434.     ("{\\\\`E}" "╚")
  435.     ("{\\\\'E}" "╔")
  436.     ("{\\\\^E}" "╩")
  437.     ("{\\\\\"I}" "╧")
  438.     ("{\\\\`I}" "╠")
  439.     ("{\\\\'I}" "═")
  440.     ("{\\\\^I}" "╬")
  441.     ("{\\\\\"O}" "╓")
  442.     ("{\\\\`O}" "╥")
  443.     ("{\\\\'O}" "╙")
  444.     ("{\\\\~O}" "╒")
  445.     ("{\\\\^O}" "╘")
  446.     ("{\\\\\"U}" "▄")
  447.     ("{\\\\`U}" "┘")
  448.     ("{\\\\'U}" "┌")
  449.     ("{\\\\^U}" "█")
  450.     ("{\\\\~n}" "±")
  451.     ("{\\\\~N}" "╤")
  452.     ("{\\\\c c}" "τ")
  453.     ("{\\\\c C}" "╟")
  454.     ("\\\\\"a" "Σ")
  455.     ("\\\\`a" "α")
  456.     ("\\\\'a" "ß")
  457.     ("\\\\~a" "π")
  458.     ("\\\\^a" "Γ")
  459.     ("\\\\\"e" "δ")
  460.     ("\\\\`e" "Φ")
  461.     ("\\\\'e" "Θ")
  462.     ("\\\\^e" "Ω")
  463.     ("\\\\\"\\\\i" "∩")
  464.     ("\\\\`\\\\i" "∞")
  465.     ("\\\\'\\\\i" "φ")
  466.     ("\\\\^\\\\i" "ε")
  467.     ("\\\\\"i" "∩")
  468.     ("\\\\`i" "∞")
  469.     ("\\\\'i" "φ")
  470.     ("\\\\^i" "ε")
  471.     ("\\\\\"o" "÷")
  472.     ("\\\\`o" "≥")
  473.     ("\\\\'o" "≤")
  474.     ("\\\\~o" "⌡")
  475.     ("\\\\^o" "⌠")
  476.     ("\\\\\"u" "ⁿ")
  477.     ("\\\\`u" "∙")
  478.     ("\\\\'u" "·")
  479.     ("\\\\^u" "√")
  480.     ("\\\\\"A" "─")
  481.     ("\\\\`A" "└")
  482.     ("\\\\'A" "┴")
  483.     ("\\\\~A" "├")
  484.     ("\\\\^A" "┬")
  485.     ("\\\\\"E" "╦")
  486.     ("\\\\`E" "╚")
  487.     ("\\\\'E" "╔")
  488.     ("\\\\^E" "╩")
  489.     ("\\\\\"I" "╧")
  490.     ("\\\\`I" "╠")
  491.     ("\\\\'I" "═")
  492.     ("\\\\^I" "╬")
  493.     ("\\\\\"O" "╓")
  494.     ("\\\\`O" "╥")
  495.     ("\\\\'O" "╙")
  496.     ("\\\\~O" "╒")
  497.     ("\\\\^O" "╘")
  498.     ("\\\\\"U" "▄")
  499.     ("\\\\`U" "┘")
  500.     ("\\\\'U" "┌")
  501.     ("\\\\^U" "█")
  502.     ("\\\\~n" "±")
  503.     ("\\\\~N" "╤")
  504.     ("\\\\\"{a}" "Σ")
  505.     ("\\\\`{a}" "α")
  506.     ("\\\\'{a}" "ß")
  507.     ("\\\\~{a}" "π")
  508.     ("\\\\^{a}" "Γ")
  509.     ("\\\\\"{e}" "δ")
  510.     ("\\\\`{e}" "Φ")
  511.     ("\\\\'{e}" "Θ")
  512.     ("\\\\^{e}" "Ω")
  513.     ("\\\\\"{\\\\i}" "∩")
  514.     ("\\\\`{\\\\i}" "∞")
  515.     ("\\\\'{\\\\i}" "φ")
  516.     ("\\\\^{\\\\i}" "ε")
  517.     ("\\\\\"{i}" "∩")
  518.     ("\\\\`{i}" "∞")
  519.     ("\\\\'{i}" "φ")
  520.     ("\\\\^{i}" "ε")
  521.     ("\\\\\"{o}" "÷")
  522.     ("\\\\`{o}" "≥")
  523.     ("\\\\'{o}" "≤")
  524.     ("\\\\~{o}" "⌡")
  525.     ("\\\\^{o}" "⌠")
  526.     ("\\\\\"{u}" "ⁿ")
  527.     ("\\\\`{u}" "∙")
  528.     ("\\\\'{u}" "·")
  529.     ("\\\\^{u}" "√")
  530.     ("\\\\\"{A}" "─")
  531.     ("\\\\`{A}" "└")
  532.     ("\\\\'{A}" "┴")
  533.     ("\\\\~{A}" "├")
  534.     ("\\\\^{A}" "┬")
  535.     ("\\\\\"{E}" "╦")
  536.     ("\\\\`{E}" "╚")
  537.     ("\\\\'{E}" "╔")
  538.     ("\\\\^{E}" "╩")
  539.     ("\\\\\"{I}" "╧")
  540.     ("\\\\`{I}" "╠")
  541.     ("\\\\'{I}" "═")
  542.     ("\\\\^{I}" "╬")
  543.     ("\\\\\"{O}" "╓")
  544.     ("\\\\`{O}" "╥")
  545.     ("\\\\'{O}" "╙")
  546.     ("\\\\~{O}" "╒")
  547.     ("\\\\^{O}" "╘")
  548.     ("\\\\\"{U}" "▄")
  549.     ("\\\\`{U}" "┘")
  550.     ("\\\\'{U}" "┌")
  551.     ("\\\\^{U}" "█")
  552.     ("\\\\~{n}" "±")
  553.     ("\\\\~{N}" "╤")
  554.     ("\\\\c{c}" "τ")
  555.     ("\\\\c{C}" "╟")
  556.     ("{\\\\ss}" "▀")
  557.     ("{\\\\AE}" "\306")
  558.     ("{\\\\ae}" "\346")
  559.     ("{\\\\AA}" "\305")
  560.     ("{\\\\aa}" "\345")
  561.     ("{\\\\copyright}" "\251")
  562.     ("\\\\copyright{}" "\251")
  563.     ("{\\\\pounds}" "ú" )
  564.     ("{\\\\P}" "╢" )
  565.     ("{\\\\S}" "º" )
  566.     ("\\\\pounds{}" "ú" )
  567.     ("\\\\P{}" "╢" )
  568.     ("\\\\S{}" "º" )
  569.     ("?`" "┐")
  570.     ("!`" "í")
  571.     ("{?`}" "┐")
  572.     ("{!`}" "í")
  573.     ("\"a" "Σ")
  574.     ("\"A" "─")
  575.     ("\"o" "÷")
  576.     ("\"O" "╓")
  577.     ("\"u" "ⁿ")
  578.     ("\"U" "▄")
  579.     ("\"s" "▀")
  580.     ("\\\\3" "▀")
  581.     )
  582.   "Translation table for translating German TeX sequences to ISO 8859-1.
  583. This table is not exhaustive (and due to TeX's power can never be).  It only
  584. contains commonly used sequences.")
  585.  
  586. (defvar iso-iso2gtex-trans-tab
  587.   '(
  588.     ("Σ" "\"a")
  589.     ("α" "{\\\\`a}")
  590.     ("ß" "{\\\\'a}")
  591.     ("π" "{\\\\~a}")
  592.     ("Γ" "{\\\\^a}")
  593.     ("δ" "{\\\\\"e}")
  594.     ("Φ" "{\\\\`e}")
  595.     ("Θ" "{\\\\'e}")
  596.     ("Ω" "{\\\\^e}")
  597.     ("∩" "{\\\\\"\\\\i}")
  598.     ("∞" "{\\\\`\\\\i}")
  599.     ("φ" "{\\\\'\\\\i}")
  600.     ("ε" "{\\\\^\\\\i}")
  601.     ("÷" "\"o")
  602.     ("≥" "{\\\\`o}")
  603.     ("≤" "{\\\\'o}")
  604.     ("⌡" "{\\\\~o}")
  605.     ("⌠" "{\\\\^o}")
  606.     ("ⁿ" "\"u")
  607.     ("∙" "{\\\\`u}")
  608.     ("·" "{\\\\'u}")
  609.     ("√" "{\\\\^u}")
  610.     ("─" "\"A")
  611.     ("└" "{\\\\`A}")
  612.     ("┴" "{\\\\'A}")
  613.     ("├" "{\\\\~A}")
  614.     ("┬" "{\\\\^A}")
  615.     ("╦" "{\\\\\"E}")
  616.     ("╚" "{\\\\`E}")
  617.     ("╔" "{\\\\'E}")
  618.     ("╩" "{\\\\^E}")
  619.     ("╧" "{\\\\\"I}")
  620.     ("╠" "{\\\\`I}")
  621.     ("═" "{\\\\'I}")
  622.     ("╬" "{\\\\^I}")
  623.     ("╓" "\"O")
  624.     ("╥" "{\\\\`O}")
  625.     ("╙" "{\\\\'O}")
  626.     ("╒" "{\\\\~O}")
  627.     ("╘" "{\\\\^O}")
  628.     ("▄" "\"U")
  629.     ("┘" "{\\\\`U}")
  630.     ("┌" "{\\\\'U}")
  631.     ("█" "{\\\\^U}")
  632.     ("±" "{\\\\~n}")
  633.     ("╤" "{\\\\~N}")
  634.     ("τ" "{\\\\c c}")
  635.     ("╟" "{\\\\c C}")
  636.     ("▀" "\"s")
  637.     ("\306" "{\\\\AE}")
  638.     ("\346" "{\\\\ae}")
  639.     ("\305" "{\\\\AA}")
  640.     ("\345" "{\\\\aa}")
  641.     ("\251" "{\\\\copyright}")
  642.     ("ú" "{\\\\pounds}")
  643.     ("╢" "{\\\\P}")
  644.     ("º" "{\\\\S}")
  645.     ("┐" "{?`}")
  646.     ("í" "{!`}")
  647.     )
  648.   "Translation table for translating ISO 8859-1 characters to German TeX.")
  649.  
  650. (defun iso-gtex2iso ()
  651.  "Translate German TeX sequences to ISO 8859-1 characters."
  652.  (interactive)
  653.  (iso-translate-conventions iso-gtex2iso-trans-tab))
  654.  
  655.  
  656. (defun iso-iso2gtex ()
  657.  "Translate ISO 8859-1 characters to German TeX sequences."
  658.  (interactive)
  659.  (iso-translate-conventions iso-iso2gtex-trans-tab))
  660.  
  661.  
  662. (defun iso-german-tex-p ()
  663.  "Check if tex buffer is German LaTeX."
  664.  (save-excursion
  665.    (save-restriction
  666.      (widen)
  667.      (goto-char (point-min))
  668.      (re-search-forward "\\\\documentstyle\\[.*german.*\\]" nil t))))
  669.  
  670. (defun iso-fix-iso2tex ()
  671.   "Turn ISO 8859-1 (aka. ISO Latin-1) buffer into TeX sequences.
  672. If German TeX is used, German TeX sequences are generated."
  673.   (if (or (equal major-mode 'latex-mode)
  674.       (equal major-mode 'LaTeX-mode)) ; AucTeX wants this
  675.       (if (iso-german-tex-p)
  676.       (iso-iso2gtex)
  677.     (iso-iso2tex)))
  678.   (if (or (equal major-mode 'tex-mode)
  679.       (equal major-mode 'TeX-mode) ; AucTeX wants this
  680.       (equal major-mode 'plain-tex-mode))
  681.       (iso-iso2tex)))
  682.  
  683. (defun iso-fix-tex2iso ()
  684.   "Turn TeX sequences into ISO 8859-1 (aka. ISO Latin-1) characters.
  685. This function recognices German TeX buffers."
  686.   (if (or (equal major-mode 'latex-mode)
  687.       (equal major-mode 'Latex-mode)) ; AucTeX wants this
  688.       (if (iso-german-tex-p)
  689.       (iso-gtex2iso)
  690.     (iso-tex2iso)))
  691.   (if (or (equal major-mode 'tex-mode)
  692.       (equal major-mode 'TeX-mode)  ; AucTeX wants this
  693.       (equal major-mode 'plain-tex-mode))
  694.       (iso-tex2iso)))
  695.  
  696. (defun iso-cvt-ffh ()
  697.   "find-file-hook for iso-cvt.el."
  698.   (iso-fix-tex2iso)
  699.   (set-buffer-modified-p nil))
  700.  
  701. (defun iso-cvt-wfh ()
  702.   "write file hook for iso-cvt.el."
  703.   (iso-fix-iso2tex))
  704.  
  705. (defun iso-cvt-ash ()
  706.   "after save hook for iso-cvt.el."
  707.   (iso-fix-tex2iso)
  708.   (set-buffer-modified-p nil))
  709.  
  710. (add-hook 'find-file-hooks 'iso-cvt-ffh)
  711. (add-hook 'write-file-hooks 'iso-cvt-wfh)
  712. (add-hook 'after-save-hook 'iso-cvt-ash)
  713.  
  714. ;;; iso-cvt.el ends here
  715.